<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta name="keywords" content="LightYear,LightYearAdmin,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="Light Year Admin V5是一个基于Bootstrap v5.1.3的后台管理系统的HTML模板。">
<title>新增文档 - 光年(Light Year Admin V5)后台管理系统模板</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/bootstrap.min.css">
<!--tags插件css-->
<link type="text/css" rel="stylesheet" href="__STATIC__/admin/js/jquery-tagsinput/jquery.tagsinput.min.css">
<!--上传插件css-->
<link type="text/css" rel="stylesheet" href="__STATIC__/admin/js/webuploader/webuploader.css">
<!--引入下拉插件css-->
<!-- <link rel="stylesheet" type="text/css" href="__STATIC__/admin/js/bootstrap-select/bootstrap-select.min.css"> -->
<link href="__STATIC__/common/select2/select2.css" rel="stylesheet">
<!--灯箱效果插件css-->
<link type="text/css" rel="stylesheet" href="__STATIC__/admin/js/magnific-popup/magnific-popup.min.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/animate.min.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/style.min.css">
</head>
  
<body>
<div class="container-fluid">
  
  <div class="row">
    
    <div class="col-lg-12">
      <div class="card">
        <!-- <header class="card-header"><div class="card-title">新增文档</div></header> -->
        <div class="card-body">
          
          <form action="" method="post" class="row">
   

            <div class="row mb-3">
                <?php $field = 'company_id'; $vo = ['name'=>'所属公司','type'=>'select1','params'=>$companys]; ?>
                <div class="col-md-6">
                  {include file="html/fields/select1" /}
                </div>

                <?php $field = 'department_id'; $vo = ['name'=>'分支机构','type'=>'select1','params'=>$departments]; ?>
                <div class="col-md-6">
                  {include file="html/fields/select1" /}
                </div>
            </div>

         

            {include file="html/fields" /}


            <div class="mb-3 col-md-12">
              <?php $field = 'wy_company_id'; $vo = ['name'=>'文员权限','type'=>'checkbox','params'=>$companys]; ?>
              {include file="html/fields/checkbox" /}
            </div>

            <!-- <div class="mb-3 col-md-12">
              <?php $field = 'gj_company_id'; $vo = ['name'=>'估价师权限','type'=>'checkbox','params'=>$companys]; ?>
              {include file="html/fields/checkbox" /}
            </div> -->

            <div class="mb-3 col-md-12">
              <?php $field = 'pg_company_id'; $vo = ['name'=>'评估员权限','type'=>'checkbox','params'=>$companys]; ?>
              {include file="html/fields/checkbox" /}
            </div>

            <div class="mb-3 col-md-12">
              <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确 定</button>
              <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
          </form>
          
        </div>
      </div>
    </div>
        
  </div>
  
</div>
<script type="text/javascript" src="__STATIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/popper.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap.min.js"></script>
<!--tags插件-->
<script type="text/javascript" src="__STATIC__/admin/js/jquery-tagsinput/jquery.tagsinput.min.js"></script>
<!--上传插件-->
<script type="text/javascript" src="__STATIC__/admin/js/webuploader/webuploader.js"></script>
<!--灯箱效果插件-->
<script type="text/javascript" src="__STATIC__/admin/js/magnific-popup/magnific-popup.min.js"></script>
<!--通知消息插件-->
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/main.min.js"></script>
<!--省市选择-->
<script type="text/javascript" src="__STATIC__/common/distpicker/distpicker.data.js"></script>
<script type="text/javascript" src="__STATIC__/common/distpicker/distpicker.js"></script>
<!--引入下拉插件js-->
<!-- <script type="text/javascript" src="__STATIC__/admin/js/bootstrap-select/bootstrap-select.min.js"></script> -->
<script src="__STATIC__/common/select2/select2.min.js"></script>
<!--自定义扩展-->
<script type="text/javascript" src="__STATIC__/common/cch.js"></script>
{include file="html/jspath" /}
<script type="text/javascript">
  $(function(){
    updateRole();
  });

  $("#company_id").on('change',function(){
    $.ajax({
        url:'{:url("Department/indexForAjax")}',
        data:{company_id:$(this).val()},
        type:'post',
        dataType:'json',
        success:function(data){
          var str = '';
          for(var i in data){
            str += '<option value="'+i+'">'+data[i]+'</option>';
          }
          $("#department_id").html(str);
        }
    });

    updateRole();
  });

  $("input[name='role[]']").on('click',function(){
    updateRole();
  });

  function updateRole(){
    var company_id = $("#company_id").val();
    var role = [];
    $("input[name='role[]']:checked").each(function(){
      role.push($(this).val());
    });
    console.log(role)
    if (company_id == 1) {
      $("input[name='wy_company_id[]']").parent().parent().parent().hide();
    }else if( $.inArray( 'wy', role ) > -1 ){
      $("input[name='wy_company_id[]']").parent().parent().parent().show();
    }else{
      $("input[name='wy_company_id[]']").parent().parent().parent().hide();
    }
    // 估价师权限
    if( $.inArray( 'gj', role ) > -1 ){
      $("input[name='gj_company_id[]']").parent().parent().parent().show();
    }else{
      $("input[name='gj_company_id[]']").parent().parent().parent().hide();
    }
    // 评估员权限
    if( $.inArray( 'pg', role ) > -1 ){
      $("input[name='pg_company_id[]']").parent().parent().parent().show();
    }else{
      $("input[name='pg_company_id[]']").parent().parent().parent().hide();
    }
  }


</script>
</body>
</html>